package controller

import (
	"bytes"
	"encoding/json"
	"github.com/gin-gonic/gin"
	"log"
	"net/http"
)

func JsonPage(c *gin.Context) {
	c.HTML(http.StatusOK, "json.html", gin.H{})
}

func JsonFormat(c *gin.Context) {
	in := c.PostForm("in")
	var out bytes.Buffer
	err := json.Indent(&out, []byte(in), "", "	")
	if err != nil {
		log.Printf("Json Indenty by in:%v Error:%v", in, err)
	}
	c.JSON(http.StatusOK, gin.H{
		"out": out.String(),
	})
}
